use hysteria_server::{
    auth::PasswordAuthenticator,
    config::{ServerConfig, TlsConfig, AuthConfig, BandwidthConfig},
    HysteriaServer,
};
use std::sync::Arc;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Initialize logging
    tracing_subscriber::fmt::init();

    // Create server configuration
    let config = ServerConfig {
        listen: "0.0.0.0:443".parse()?,
        obfs: Default::default(),
        tls: Some(TlsConfig {
            cert: "cert.pem".to_string(),
            key: "key.pem".to_string(),
        }),
        bandwidth: BandwidthConfig {
            up: "1 gbps".to_string(),
            down: "1 gbps".to_string(),
        },
        ignore_client_bandwidth: false,
        disable_udp: false,
        udp_idle_timeout: std::time::Duration::from_secs(60),
        auth: AuthConfig::Password {
            password: "your_password".to_string(),
        },
        traffic_stats: None,
        masquerade: Default::default(),
    };

    // Create authenticator
    let authenticator = Arc::new(PasswordAuthenticator::new("your_password".to_string()));

    // Create and start server
    let server = HysteriaServer::new(config, authenticator)?;
    server.serve().await?;

    Ok(())
}
